package cn.hjh.service;

import cn.hjh.dao.DeliMapper;
import cn.hjh.pojo.Goods;
import cn.hjh.pojo.GoodsType;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DeliServiceImpl implements DeliService {

    @Resource
    private DeliMapper deliMapper;

    @Override
    public List<Goods> getGoodsList() {
        return deliMapper.getGoodsList();
    }

    @Override
    public Map<String, List<Goods>> getGoodsTypeList() {
        HashMap<String,List<Goods>> goodsMap=new HashMap<>();

        List<GoodsType> goodsTypeList=deliMapper.getGoodsTypeList();

        for (int i = 0; i < goodsTypeList.size(); i++) {
            goodsMap.put("type"+goodsTypeList.get(i).getId(), deliMapper.getGoodsType(goodsTypeList.get(i).getId()));
        }
        return goodsMap;
    }

}
